<?php
/**
 * XuYuan Project
 *
 * @package	XueYuan 
 * @author	Jiuchi Team
 * @since	Version 1.0.0
 * @filesource
 */
defined('BASEPATH') OR exit('No direct script access allowed');
/**
 * User model class
 * @author Wayne Yu
 */
class Circle_applicant_model extends Jiuchi_Model{
	/**
	 * Construct function
	 */
	public function __construct() {
		parent::__construct();
		
		$this->table = 'circle_applicant';
	}
	
	public function checkIsApplying($uid, $cid){
		$count = 1;
		$res = $this->retrieve($count, NULL, NULL, NULL, array('user_id' => $uid, 'circle_id' => $cid, 'is_reviewed' => 0));
		if($res){
			return TRUE;
		} else{
			return FALSE;
		}
	}

	public function refuseApply($aid){
		$res = $this->db->delete($this->table, array('id' => $aid));
		return $res;
	}

	public function cleardata($uid, $cid){
		$res = $this->db->delete($this->table, array('user_id' => $uid, 'circle_id' => $cid));
		return $res;
	}
}